const {ipcMain} = require('electron')
const {create:createControlWindow} = require('../main/windows/control')
const {send:sendMainWindow} = require('../main/windows/main')
module.exports = function(){
  ipcMain.handle('login',async()=>{//监听login
    //先mock,返回一个code
    let code = Math.floor(Math.random()*(999999-100000))+10000
    return code
  })
  ipcMain.on('control',async(e,remoteCode)=>{
    //应与服务器交互,直接mock返回,告诉渲染进程已经被控制
    sendMainWindow('control-state-change',remoteCode,1)
    createControlWindow()
  })
}
